#ifndef INDICATORS_H
#define INDICATORS_H
#include <QLabel>
#include "qdock.h"
#include <functional>

class QIndicator : public QLabel{
    Q_OBJECT
public:
    void setHovered(bool value);
    virtual DockOption dockoption() = 0;
    virtual void resizeIndicator(const QRect &rec);
    void updatePixmap(int size);
    void setTarget(QWidget* target){ m_target = target;}
    QWidget* target(){return m_target;}
protected:
    QIndicator(QWidget* parent, QIcon icon);
    virtual void resizeEvent(QResizeEvent * event);
protected:
    QIcon m_icon;
    bool m_hovered;
    int m_iconsize;
    QWidget* m_target;
};

class QLeftIndicator : public QIndicator {
    Q_OBJECT
public:
    QLeftIndicator(QWidget* parent = 0);
    virtual DockOption dockoption(){return DockOption::Left;}

};

class QRightIndicator : public QIndicator {
    Q_OBJECT
public:
    QRightIndicator(QWidget* parent = 0);
    virtual DockOption dockoption(){return DockOption::Right;}
};

class QBottomIndicator : public QIndicator {
    Q_OBJECT
public:
    QBottomIndicator(QWidget* parent = 0);
    virtual DockOption dockoption(){return DockOption::Bottom;}
};

class QTopIndicator : public QIndicator {
    Q_OBJECT
public:
    QTopIndicator(QWidget* parent = 0);
    virtual DockOption dockoption(){return DockOption::Top;}
};

class QTabbedIndicator : public QIndicator {
    Q_OBJECT
public:
    QTabbedIndicator(QWidget* parent = 0);
    virtual DockOption dockoption(){return DockOption::Tabbed;}
};

class IndividualIndicators {

public:
    IndividualIndicators();
    ~IndividualIndicators();
    void put(QWidget* target, QList<QRect> obstacles, DockOption dockoptions);
    QIndicator* hoveredIndicator(const QPoint & point);
    QWidget* currentTarget() const;
    void hide();
protected:
    void mapToIndicators(std::function<void(QIndicator*)> foo);

    struct CenterAndSize {
        int iconsize;
        QPoint center;
    };

    CenterAndSize optimizedCenter(QList<QRect> maxRects, const QPoint &preferred_center, DockOption dockoptions);
protected:
    QWidget* m_target;
    QBottomIndicator* m_bottom_indicator;
    QTopIndicator* m_top_indicator;
    QLeftIndicator* m_left_indicator;
    QRightIndicator* m_right_indicator;
    QTabbedIndicator* m_tabbed_indicator;
};

#endif // INDICATORS_H
